﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<UI.Models.SearchProductModel>" %>

<%@ Import Namespace="UI.Helper" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <table width="100%" cellspacing="0" cellpadding="0">
        <tr>
            <td valign="top">
                <table width="100%" cellspacing="0" cellpadding="0">
                    <tr>
                        <td>
                            <table width="100%" cellpadding="0" cellspacing="0">
                                <tbody>
                                    <tr>
                                        <td width="12" align="left">
                                            <img src="<%= Url.Content("~/Images/bg-title-blue-left.png") %>" width="12" height="46">
                                        </td>
                                        <td class="Bgtitle">
                                            <table width="100%" cellspacing="0" cellpadding="0">
                                                <tr>
                                                    <td class="Title-white">
                                                        <div id="CategoryName"><%: Model.NameSearch.ToUpper()%></div>
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                        <td width="17" align="left">
                                            <img src="<%= Url.Content("~/Images/bg-title-blue-right.png") %>" width="17" height="46">
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </td>
                    </tr>
                    <tr align="left">
                        <td style="padding-top: 5px;" >
                            <table width="100%" cellspacing="0" cellpadding="0">
                                <%  
                                    for (var i = 0; i< Model.ProductDetails.Count();i++)
                                {
                                        
                                    var j = 0;
                                %>
                                <tr>
                                    <% for (j = i; (j < i + 3) && (j < Model.ProductDetails.Count()); j++)
                                       {
                                           var tmp = Model.ProductDetails.ElementAt(j);
                                    %>
                                    <td valign="top" >
                                        <table width="212" style="height: 250px" cellpadding="0" cellspacing="0" class="Table">
                                            <tr>
                                                <td valign="top">
                                                    <table width="100%" cellspacing="2" cellpadding="2">
                                                        <tr>
                                                            <td>
                                                                <img src="<%= Url.Content(tmp.liImages.FirstOrDefault().Url)%>" width="202" height="112" />
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td>
                                                                <span class="Title-blue-small">
                                                                    <%: tmp.Name%></span><br />
                                                                <span class="Text-blue">
                                                                    <%= tmp.Description.Trim().Substring(0, 300)%>...</span>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td>
                                                                <div align="right">
                                                                    <span class="Link-organe">
                                                                        <%: Html.ActionLink("Xem tiếp", "Detail", new { controller = "Product", ID = tmp.ProductId }, new { @class = "Link-organe" })%>
                                                                    </span>&nbsp;
                                                                    <img src="<%= Url.Content("~/Images/arrow-organe.gif")%>" width="4" height="7" /></div>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                    <%}
                                    i = j;
                                      %>
                                </tr>
                                <% } %>
                            </table>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td></br></td>
        </tr>
        <tr>
            <td style="float:right" >
                <!--  start paging..................................................... -->
                <% if (Model.ProductDetails.Count() > 0)
                   {
                       
                %>
			    <table border="0" cellpadding="0" cellspacing="0" id="paging-table">
			    <tr>
			    <td>
                    <%: Html.ActionLink(" ", "Search", new { controller = "Product", page = 1, province= Model.provinceID , district= Model.districtID }, new { @class = "page-far-left" })%>
                    <%: Html.ActionLink(" ", "Search", new { controller = "Product", page = ((int)ViewData[Constants.PAGE_INDEX] - 1) < 1 ? 1 : ((int)ViewData[Constants.PAGE_INDEX] - 1), province = Model.provinceID, district = Model.districtID }, new { @class = "page-left" })%>
				    <div id="page-info">Page <strong><%: ViewData[Constants.PAGE_INDEX]%></strong> / <%: ViewData[Constants.TOTAL_PAGE]%></div>
                    <%: Html.ActionLink(" ", "Search", new { controller = "Product", page = ((int)ViewData[Constants.PAGE_INDEX] + 1) > (int)ViewData[Constants.TOTAL_PAGE] ? ViewData[Constants.TOTAL_PAGE] : ((int)ViewData[Constants.PAGE_INDEX] + 1), province = Model.provinceID, district = Model.districtID }, new { @class = "page-right" })%>
                    <%: Html.ActionLink(" ", "Search", new { controller = "Product", page = ViewData[Constants.TOTAL_PAGE], province = Model.provinceID, district = Model.districtID }, new { @class = "page-far-right" })%>
			    </td>
			    </tr>
			    </table>
                <% } %>
			    <!--  end paging................ -->
            </td>
        </tr>
    </table>
    
</asp:Content>
